
// MyMusicPlayerDlg.h : header file
//
#pragma once
#include "afxwin.h"
#include "afxcmn.h"
#include "dshow.h"
//
#pragma comment(lib,"Strmiids.lib")
#define MAX_SIZE 256
#define MY_TIMEREVENT 9991
#define WM_GRAPHNOTIFY  WM_APP + 1


// CMyMusicPlayerDlg dialog
class CMyMusicPlayerDlg : public CDialog
{

	// DECLARE_EASYSIZE
// Construction
public:
	CMyMusicPlayerDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_MYMUSICPLAYER_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support



// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()


private:
	CMenu m_Menu;
public:
	CStatic m_stcPlaying;
	CSliderCtrl m_SliderTimeLife;
	CStatic m_stcTimePlay;
	CStatic m_stcTimeTotal;
	CSliderCtrl m_sliderVolume;
	CButton m_btnPlay;
	CButton m_btnStop;

	//variable
	CString m_strPathFile;
	CString m_strNameFile;
    char szFileName[MAX_SIZE];
	CString m_strPlay;
	CString m_strPause;
	bool m_bPlaying;
	bool m_bInit;
	long totalDuration;
	long lvolume;
	long timeElapsed;
	float step;
	HWND hOwner;
	REFERENCE_TIME m_timenow;
	REFERENCE_TIME m_tplay;
	LONGLONG lTotalDuration;

	//---
	IGraphBuilder *pGraphBuilder;   //manage Graph
	IMediaControl *pMediaControl;	// control media
	IMediaSeeking *pMediaSeeking;	// Manage time of media
	IMediaEventEx *pMediaEventEx;	// process event of graph
	IBasicAudio   *pAudio;           //manage volume
	//--- 
	void Initialize(HWND owner);
	int StartPlayingFile();
	int PlayPause();
	int DoStop();
	int DoTimeStuff();
    int ReleaseVal();
	int HanldeEventFromGraph();

   virtual BOOL PreTranslateMessage(MSG* pMsg);

	afx_msg void OnBnClickedBtnPlay();
	afx_msg void OnBnClickedBtnStop();
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnNMReleasedcaptureSldVolume(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnNMReleasedcaptureSldLife(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnFileOpenfile();
	afx_msg void OnFileExit();
	/*afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnSizing(UINT fwSide, LPRECT pRect);*/
	afx_msg void OnControlPausePlay();
	afx_msg void OnControlStop();
	afx_msg void openfile();
};
